package com.briup.sxau.conf;

import com.briup.sxau.util.Result;
import com.briup.sxau.util.SxauException;
import io.jsonwebtoken.JwtException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler
    public Result handler(Exception e) {
        if (e instanceof SxauException) {
            return Result.error(500, e.getMessage());
        }else if (e instanceof JwtException){
            return Result.error(501,"token无效错误");
        }else {
            return Result.error(502,"系统内部错误");
        }
    }
}